﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Agile.Engine.View;
using System.Collections;
using Agile.Engine;
using Agile.Engine.Data;

namespace Fis.Win.Rules
{
    public class InitializeViewProvider : ClientViewProvider
    {
        public string Master { get; set; }
        public string Detail { get; set; }
        public override Hashtable InitializeViewModel(Hashtable args)
        {
            return ExecuteQuery(args);
        }
        public override Hashtable ExecuteQuery(object param)
        {
            Hashtable model = param as Hashtable;
            var filter1 = model["filter1"].ToString();
            var sql = ObjectContext.GetResource("SqlResource").Format("billQuery", model["filter0"]
                , string.IsNullOrEmpty(filter1) ? string.Empty : ObjectContext.GetResource("SqlResource").Format("billSubQuery", filter1));
            model["BillData"] = DataContext.DefaultModel.QueryTable(System.Data.CommandType.Text, DataTableName, sql);
            return model;
        }
    }

}
